package cn.org.guhao.practice.zk.controller;

import cn.org.guhao.practice.zk.service.ZkService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

/**
 * TestController
 *
 * @author guhao
 * @since 2020/6/7
 */
@RestController
@RequestMapping("/zk")
public class ZkController {

  private static final Logger LOGGER = LoggerFactory.getLogger(ZkController.class);

  private final ZkService zkService;

  public ZkController(ZkService zkService) {
    this.zkService = zkService;
  }

  @PostMapping("/node/{from}/{to}")
  public String createNode(@PathVariable("from") Integer from,@PathVariable("to") Integer to){
    LOGGER.info("welcome create [{}] to [{}] node", from, to);
    zkService.create("/sw8/zk/log", from, to);
    return "hello zk";
  }

}
